# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id: rc.eselect 246 2005-12-05 23:07:53Z kugelfang $ DESCRIPTION="Manage /etc/init.d scripts in runlevels" MAINTAINER="Danny van Dyk " SVN_DATE='$Date: 2005-12-05 23:07:53 +0000 (Mon, 05 Dec 2005) $' VERSION=$(svn_date_to_version "${SVN_DATE}") # global setting RC_SOFTLEVEL=/var/lib/init.d/softlevel # list_runlevels PRIVATE # list runlevels for file $1 list_runlevels() { [[ ${#@} -eq 1 ]] || return local runlevels for x in ${ROOT}/etc/runlevels/* ; do [[ -d ${x} ]] || continue [[ -L ${ROOT}/etc/runlevels/${x##*/}/${file} ]] \ && runlevels=(${runlevels[@]} "${x##*/}") done echo -ne "${runlevels[@]}" } # is_script PRIVATE # check if file $1 is a valid init script is_script() { local file=${1} [[ -n ${file} ]] \ || return 1 ( [[ -L ${file} ]] \ && [[ ! -e $(dirname ${file})/$(readlink ${file}) ]] ) \ && return 1 [[ -e ${file} ]] \ && [[ ${file%%.sh} == ${file} ]] \ && [[ ${file%%\~} == ${file} ]] \ && [[ -n `grep "^#\!/sbin/runscript" ${file}` ]] } # find_scripts PRIVATE # browse directory $1 for init scripts and return a list find_scripts() { local ret for file in ${1}/* ; do is_script ${file} \ && ret=(${ret[@]} "${file##*/}") done echo -ne ${ret[@]} } # run_runscript PRIVATE # run RC_RUNSCRIPT with script $2- and command $1 run_runscript() { local command=${1} shift write_list_start "${1}" shift for script in ${@} ; do is_script ${ROOT}/etc/init.d/${script} \ && /sbin/runscript ${ROOT}/etc/init.d/${script} ${command} done } ### add action describe_add() { echo "Add script to existing runlevel(s)" } describe_add_parameters() { echo "